package com.google.code.swingonfire.utility.date;

import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Locale;

public class DateRenderInfoAlternateHourOfDayPart extends AbstractDateRenderInfoPart
{

    public DateRenderInfoAlternateHourOfDayPart(int length)
    {
        super(length);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected String getValue(Calendar calendar, DateFormatSymbols dateFormatSymbols, Locale locale)
    {
        int value = calendar.get(Calendar.HOUR_OF_DAY);

        if (value == 0)
        {
            value = calendar.getMaximum(Calendar.HOUR_OF_DAY) + 1;
        }

        return formatNumber(value);
    }

}
